diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c
index 3239e30..e3d4dcd 100644
--- a/src/video/directfb/SDL_DirectFB_shape.c
+++ b/src/video/directfb/SDL_DirectFB_shape.c
@@ -37,18 +37,20 @@ DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsi
 SDL_WindowShaper*
 DirectFB_CreateShaper(SDL_Window* window) {
     SDL_WindowShaper* result = NULL;
-
+    SDL_ShapeData* data = NULL;
+    int resized_properly = 0;
+    
     result = malloc(sizeof(SDL_WindowShaper));
     result->window = window;
     result->mode.mode = ShapeModeDefault;
     result->mode.parameters.binarizationCutoff = 1;
     result->userx = result->usery = 0;
-    SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
     result->driverdata = data;
     data->surface = NULL;
     window->shaper = result;
-    int resized_properly = DirectFB_ResizeWindowShape(window);
     SDL_assert(resized_properly == 0);
+    data = SDL_malloc(sizeof(SDL_ShapeData));
+    resized_properly = DirectFB_ResizeWindowShape(window);
 
     return result;
 }
